package com.hooper.config;

import com.hooper.aop.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2023/04/02/19:40
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Bean
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/doc.html", "/swagger-resources/**",
                        "/webjars/**", "/v2/**", "/swagger-ui.html/**")
                .order(1);
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
